package com.bestcem.xm.award.controller.param.draw;

import com.alibaba.fastjson.JSON;
import com.bestcem.xm.award.grpc.service.param.draw.DrawAwardParam;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * 抽奖请求参数
 *
 * @author hang.li <hang.li@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/20 10:24
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DrawAwardRequestParam {

    /**
     * 抽奖请求数据
     */
    @NotNull(message = "奖励数据{award}缺失")
    @JsonProperty(value = "award")
    private Map<String, Object> award;

    /**
     * 抽奖请求参数转换
     * @return {@link DrawAwardParam}
     */
    public DrawAwardParam getDrawAwardParam() {
        return JSON.parseObject(JSON.toJSONString(this.award), DrawAwardParam.class);
    }
}
